package ${packageName};

import jakarta.persistence.*;
import lombok.Data;
<#if imports?has_content>
<#list imports as import>
import ${import};
</#list>
</#if>
import java.io.Serializable;

/**
 * ${table.comment!table.name} 实体类
 * 表名：${table.name}
 * 自动生成的实体类
 */
@Data
@Entity
@Table(name = "${table.name}")
public class ${table.className} implements Serializable {

    private static final long serialVersionUID = 1L;
    
<#list table.columns as column>
    /**
     * ${column.comment!column.name}
     <#if column.primaryKey>
     * 主键
     </#if>
     <#if column.defaultValue?? && column.defaultValue?length gt 0>
     * 默认值: ${column.defaultValue}
     </#if>
     */
    <#if column.primaryKey>
    @Id
    <#if column.name?upper_case == "ID" && column.sqlType?upper_case == "INT">
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    </#if>
    </#if>
    @Column(name = "${column.name}"<#if !column.nullable>, nullable = false</#if><#if column.length gt 0 && column.javaType == "String">, length = ${column.length?replace(",", "")}</#if>)
    private ${column.javaType} ${column.javaName};
    
</#list>
    @Override
    public String toString() {
        return "${table.className}{" +
        <#list table.columns as column>
            "<#if column_index != 0>, </#if>${column.javaName}=" + ${column.javaName} +
        </#list>
        '}';
    }
} 